package proxy;

/**
 * @ClassName ProxyPatternDemo
 * @Description 代理模式, 用于增强原有类的指定方法
 * @Author leejiliang
 * @DateTime 2021/2/24 15:07
 * @Version 1.0
 */
public class ProxyPatternDemo {

	public static void main(String[] args) {
		Eat eat = new EatProxy(new EatImpl());
		eat.eating();
	}

	interface Eat {
		void eating();
	}

	static class EatImpl implements Eat {
		@Override
		public void eating() {
			System.out.println("我正在用筷子吃东西");
		}
	}

	static class EatProxy implements Eat {


		private Eat eat;

		public EatProxy(Eat eat) {
			this.eat = eat;
		}

		@Override
		public void eating() {
			System.out.println("吃饭之前先洗个手");
			eat.eating();
		}
	}

}
